package it.sources.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import it.sources.user.domain.User;
import it.sources.user.mapper.UserMapper;
import it.sources.user.service.IUserService;
import it.sources.user.domain.query.UserQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import it.sources.untile.R;

import java.util.List;
@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper ump;
    @Override
    public List<User> findAll() {
        return ump.findAll();
    }

    @Override
    public User findOne(Long id) {
        return ump.findOne(id);
    }

    @Override
    public void delet(Long id) {
        ump.delet(id);
    }

    @Override
    public void upDate(User user) {
        ump.upDate(user);
    }

    @Override
    public void add(User user) {
        ump.add(user);
    }

    @Override
    public R pathDele(Long[] id) {
        ump.pathDele(id);
        return R.success();
    }

    @Override
    public PageInfo<User> queryPage(UserQuery userQuery) {
        PageHelper.startPage(userQuery.getCurrentPage(), userQuery.getPageSize());
        List<User> users = ump.queryPage(userQuery);
        PageInfo<User> info = new PageInfo<User>(users);
        return  info;
    }
}
